﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DafYomiLib.UnitTests
{
    [TestClass]
    public class DafYomiUnitTests
    {
        [TestMethod]
        public void TestDafYomiMatchesForTwoDates()
        {
            var dafYomi = new DafYomi();
            // new DateTime(1931, 2, 3)
            // dafYomi.TodayDafYomi.Page.ToString();
            var testDate = new DateTime(2017, 9, 15);
            var testDateDafYomi = dafYomi.GetDafYomiOfDate(testDate);
            var testDatePlusFiveIterationsDafYomi = dafYomi.GetDafYomiOfDate(testDate.AddDays(DafYomi.NumberOfFullPagesInTalmudBavli * 5));

            Assert.AreEqual(testDateDafYomi.Tractate, testDatePlusFiveIterationsDafYomi.Tractate, "The tractate does not match");
            Assert.AreEqual(testDateDafYomi.Page, testDatePlusFiveIterationsDafYomi.Page, "The page does not match");
        }

        [TestMethod]
        public void TestDafYomiOfThirteenIterationStartDate()
        {
            var dafYomi = new DafYomi();
            // new DateTime(1931, 2, 3)
            // dafYomi.TodayDafYomi.Page.ToString();
            var testDate = new DateTime(2012, 8, 3);
            var testDateDafYomi = dafYomi.GetDafYomiOfDate(testDate);

            Assert.AreEqual(testDateDafYomi.Tractate, Tractate.Brachot, "The tractate does not match");
            Assert.AreEqual(testDateDafYomi.Page, 2, "The page does not match");
        }

        [TestMethod]
        public void TestGimatriya()
        {
            Assert.AreEqual("תשיא", Gimatriya.Convert(711));
            Assert.AreEqual("תתר", Gimatriya.Convert(1000));
            Assert.AreEqual("פז", Gimatriya.Convert(87));
            Assert.AreEqual("א", Gimatriya.Convert(1));
            Assert.AreEqual("י", Gimatriya.Convert(10));
            Assert.AreEqual("טו", Gimatriya.Convert(15));
            Assert.AreEqual("טז", Gimatriya.Convert(16));
            Assert.AreEqual("קטז", Gimatriya.Convert(116));
        }
    }
}
